﻿using BCCommon.FMISEnums;
using BCCommon.OAEnums;
using BCCommon.SCMEnums;
using BCEntity.OA.TeamWorks.TaskRecord;
using BCEntity.OA.TeamWorks.TaskRecordCount;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace BCData.OA.TeamWorks.FMISTaskRecord
{
    /// <summary>
    /// 财务系统任务记录
    /// </summary>
    public interface IFMISTaskRecordData
    {
        /// <summary>
        /// 获取财务系统任务记录
        /// </summary>
        /// <param name="taskRecordId">任务记录Id</param>
        /// <returns></returns>
        Task<FMISTaskRecordEntity> GetEntity(long taskRecordId);
        /// <summary>
        /// 获取财务系统任务记录
        /// </summary>
        /// <param name="taskRecordNo">任务记录编号</param>
        /// <returns></returns>
        Task<FMISTaskRecordEntity> GetEntity(string taskRecordNo);
        /// <summary>
        /// 获取财务系统最新任务记录
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<FMISTaskRecordEntity> GetLatestRecord(long workflowActivityInstanceId);
        /// <summary>
        /// 获取财务系统任务记录列表
        /// </summary>
        /// <param name="saleContractNo">销售合同编号</param>
        /// <returns></returns>
        Task<IEnumerable<FMISTaskRecordEntity>> Get(string saleContractNo);
        /// <summary>
        /// 获取财务系统任务记录
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<IEnumerable<FMISTaskRecordEntity>> Get(long workflowActivityInstanceId);
        /// <summary>
        /// 获取财务系统任务记录
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<IEnumerable<FMISTaskRecordEntity>> GetWithCurrentlyStep(long workflowActivityInstanceId);
        /// <summary>
        /// 添加财务系统任务记录信息
        /// </summary>
        /// <param name="fMISTaskRecordEntity">财务系统任务记录信息</param>
        /// <returns></returns>
        Task<bool> Add(FMISTaskRecordEntity fMISTaskRecordEntity);
        /// <summary>
        /// 添加财务系统任务记录信息，仅添加 fmis_taskrecord 表。
        /// </summary>
        /// <param name="fMISTaskRecordEntity">财务系统任务记录信息</param>
        /// <returns></returns>
        Task AddFmisTaskRecordAsync(FMISTaskRecordEntity fmisTaskRecordEntity);
        /// <summary>
        /// 添加财务系统任务记录信息
        /// </summary>
        /// <param name="fMISTaskRecordEntity">财务系统任务记录信息</param>
        /// <returns></returns>
        Task<bool> Append(FMISTaskRecordEntity fMISTaskRecordEntity);
        /// <summary>
        /// 获取未开始的任务记录列表
        /// </summary>
        /// <returns></returns>
        Task<IEnumerable<FMISTaskRecordEntity>> GetNoAssignedTaskRecords();
        /// <summary>
        /// 修改任务开始时间
        /// </summary>
        /// <param name="taskRecordEntity">任务记录信息</param>
        /// <returns></returns>
        Task<bool> UpdateStartTime(FMISTaskRecordEntity taskRecordEntity);
        /// <summary>
        /// 修改任务开始时间
        /// </summary>
        /// <param name="taskRecordNo">任务记录编号</param>
        /// <param name="startTime">任务开始时间</param>
        /// <returns></returns>
        Task<bool> UpdateStartTime(string taskRecordNo, DateTime? startTime);
        /// <summary>
        /// 更新执行管理员信息
        /// </summary>
        /// <param name="taskRecordEntity">财务系统任务记录信息</param>
        /// <returns></returns>
        Task<bool> UpdateExecuterAdminInfo(FMISTaskRecordEntity taskRecordEntity);
        /// <summary>
        /// 获取每日任务数量
        /// </summary>
        /// <param name="executerAdminId">任务执行人Id</param>
        /// <returns></returns>
        Task<FMISTaskRecordCountEntity> TodayRecordCount(long? executerAdminId);
        /// <summary>
        /// 获取未完成的任务数量
        /// </summary>
        /// <param name="executerAdminId">任务执行人Id</param>
        /// <returns></returns>
        Task<FMISTaskRecordCountEntity> UnfinishedCount(long? executerAdminId);
        /// <summary>
        /// 获取已异常的任务数量
        /// </summary>
        /// <param name="executerAdminId">任务执行人Id</param>
        /// <returns></returns>
        Task<FMISTaskRecordCountEntity> ExceptionCount(long? executerAdminId);
        /// <summary>
        /// 获取财务系统任务记录信息
        /// </summary>
        /// <param name="executerAdminId">任务执行人Id</param>
        /// <param name="date">日期</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="handleStatus">处理方式</param>
        /// <param name="isException">是否异常</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="companyId">公司Id</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <param name="saleContractNo">销售合同编号</param>
        /// <param name="purchaseContractNo">采购合同编号</param>
        /// <returns></returns>
        Task<(IEnumerable<FMISTaskRecordEntity>, int)> Query(long? executerAdminId, DateTime? date, DateTime? startDate, DateTime? endDate, OATaskHandleStatus? handleStatus, FMISTaskType? taskType, bool? isException,
            string sortName, int? companyId, bool? ascending, string taskExecuterFullName, string saleContractNo, string purchaseContractNo,string vehicleBrandName,
            string buyerName, int pageIndex, int pageSize);
        /// <summary>
        /// 更新任务收付款异常记录
        /// </summary>
        /// <param name="taskRecordEntities">任务记录信息列表</param>
        /// <returns></returns>
        Task<bool> UpdateTaskException(IEnumerable<FMISTaskRecordEntity> taskRecordEntities);
        /// <summary>
        /// 更新任务实收实付金额
        /// </summary>
        /// <param name="taskRecordEntities">任务记录信息列表</param>
        /// <returns></returns>
        Task<bool> UpdateActualReceiptPaymentAmount(IEnumerable<FMISTaskRecordEntity> taskRecordEntities);

        /// <summary>
        /// 新增任务抄送人信息
        /// </summary>
        /// <param name="taskReceivers">抄送人</param>
        /// <returns></returns>
        Task<bool> InsertTaskReceiverAsync(List<TaskReceiverRecordEntity> taskReceivers);
        /// <summary>
        /// 修改付款凭证应收应付金额信息
        /// </summary>
        /// <param name="taskRecordEntities"></param>
        /// <returns></returns>
        Task<bool> UpdateReceivableReceiptPaymentAmount(IEnumerable<FMISTaskRecordEntity> taskRecordEntities);
        /// <summary>
        /// 处理异常信息
        /// </summary>
        /// <param name="taskRecordEntities">任务列表</param>
        /// <returns></returns>
        Task<bool> HandleTaskException(IEnumerable<FMISTaskRecordEntity> taskRecordEntities);

        /// <summary>
        /// 更新实收金额
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <param name="actualReceiptAmount">实收金额</param>
        /// <returns></returns>
        Task<bool> UpdateActualReceiptAmount(long workflowActivityInstanceId, decimal actualReceiptAmount);

        /// <summary>
        /// 获取财务系统车辆采购合同任务记录信息
        /// </summary>
        /// <param name="executerAdminId">任务执行人Id</param>
        /// <param name="date">日期</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="handleStatus">处理方式</param>
        /// <param name="isException">是否异常</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="companyId">公司Id</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <param name="purchaseContractNo">采购合同编号</param>
        /// <param name="vehicleBrandName">品牌</param>
        /// <param name="vehiclePurchaseContractStatus">车辆采购合同状态</param>
        /// <returns></returns>
        Task<(IEnumerable<FMISTaskRecordEntity>, int)> QueryVehiclePurchaseListAsync(long? executerAdminId, DateTime? date, DateTime? startDate, DateTime? endDate, OATaskHandleStatus? handleStatus, FMISTaskType? taskType, bool? isException, string sortName, int? companyId, bool? ascending, string taskExecuterFullName, string purchaseContractNo, string vehicleBrandName, VehiclePurchaseContractStatus? vehiclePurchaseContractStatus, int pageIndex, int pageSize);

        /// <summary>
        /// 获取财务系统车辆销售合同任务记录信息
        /// </summary>
        /// <param name="executerAdminId">任务执行人Id</param>
        /// <param name="date">日期</param>
        /// <param name="startDate">开始日期</param>
        /// <param name="endDate">结束日期</param>
        /// <param name="handleStatus">处理方式</param>
        /// <param name="isException">是否异常</param>
        /// <param name="sortName">排序字段</param>
        /// <param name="companyId">公司Id</param>
        /// <param name="ascending">升序</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页数据条数</param>
        /// <param name="saleContractNo">销售合同编号</param>
        /// <param name="vehicleBrandName">品牌</param>
        /// <param name="buyerName">购买方</param>
        /// <param name="checkListStatus">车辆销售合同清单状态</param>
        /// <returns></returns>
        Task<(IEnumerable<FMISTaskRecordEntity>, int)> QueryVehicleSaleListAsync(long? executerAdminId, DateTime? date, DateTime? startDate, DateTime? endDate, OATaskHandleStatus? handleStatus, FMISTaskType? taskType, bool? isException, string sortName, int? companyId, bool? ascending, string taskExecuterFullName, string saleContractNo, string vehicleBrandName, string buyerName, VehicleSaleCheckListStatus? checkListStatus, int pageIndex, int pageSize);

        /// <summary>
        /// 获取财务系统任务记录
        /// </summary>
        /// <param name="workflowActivityInstanceId">工作流活动实例Id</param>
        /// <returns></returns>
        Task<IEnumerable<FMISTaskRecordEntity>> GetListByWorkflowActivityInstanceId(long workflowActivityInstanceId);

        /// <summary>
        /// 更新任务实收实付金额
        /// </summary>
        /// <param name="taskRecord">财务系统任务记录信息</param>
        /// <returns></returns>
        Task<int> UpdateReceivableReceiptPaymentAmount(FMISTaskRecordEntity taskRecord);

        /// <summary>
        /// 获取财务系统任务记录
        /// </summary>
        /// <param name="vehicleSaleContractNo">销售合同编号</param>
        /// <returns></returns>
        Task<IEnumerable<FMISTaskRecordEntity>> GetBySaleContractNoAsync(string vehicleSaleContractNo);
    }
}
